<?php

	/**
	 * @see Bike_Model_Mapper_Abstract
	 */
	require_once 'Bike/Model/Mapper/Abstract.php';

	/**
	 * @see Bike_Model_Mapper_Dependence
	 */
	require_once 'Bike/Model/Mapper/Dependence.php';


	class Bike_Model_Mapper_Status extends Bike_Model_Mapper_Abstract
	{
		const DB_TABLE_NAME = 'status';
		const DB_TABLE_PK_NAME = 'status_id';
		const DB_TABLE_ALIAS = 's';
		const SAVE_IN_REGISTRY = True;

		const DB_TABLE_LOCALIZATION = True;

		const TASK_VIEW_ITEMS_PER_PAGE = 5;

		static public function getInstance()
	    {
	        return self::_getInstance(__CLASS__);
	    }

	    public function getWindowTitleEdit(Bike_Model_Abstract $model)
	    {
	    	return $model->getTitle();
	    }

	    public function getStatusIdFieldParams($type = null)
	    {
	    	switch($type)
	    	{
	    		case self::PARAMS_COMMON: return array(
		    		'label' => $this->translate('Status ID'),
		    		'order' => 10,
	    		);
	    		case self::PARAMS_LIST_COLUMN: return array(
		    		'filterable' => true,
	    		);
	    		default: return array();
	    	}
	    }

	    public function getCodeFieldParams($type = null)
	    {
	    	switch($type)
	    	{
	    		case self::PARAMS_COMMON: return array(
		    		'label' => $this->translate('Code'),
		    		'order' => 20,
	    		);
	    		case self::PARAMS_LIST_COLUMN: return array(
		    		'width' => 200,
		    		'flex' => false,
		    		'filterable' => true,
	    		);
	    		case self::PARAMS_FORM_ELEMENT: return array(
		    		'description' => $this->translate("Letters and digits ONLY! Starting from uppercase!<br />Example: 'ActiveStatus'"),
		    		'required' => true,
		    		'validators' => array(
			    		array('StringLength', False, array('min' => '4')),
			    		array('Regex', False, array('pattern' => '/^[A-Z]{1}[\d\w]+$/')),
		    		),
	    		);
	    		default: return array();
	    	}
	    }

	    public function getTitleFieldParams($type = null)
	    {
	    	switch($type)
	    	{
	    		case self::PARAMS_COMMON: return array(
		    		'label' => $this->translate('Title'),
		    		//'filterable' => true,
			    	'order' => 30,
	    		);
	    		case self::PARAMS_LIST_COLUMN: return array(
		    		'width' => 200,
	    			'flex' => false,
	    			'filter' => array(
	    				'type' => 'string',
	    			),
	    		);
	    		case self::PARAMS_FORM_ELEMENT: return array(
		    		'required' => true,
					'validators' => array(
						array('StringLength', False, array('min' => '4')),
					),
	    		);
	    		default: return array();
	    	}
	    }
	}


	/*class Bike_Model_Mapper_Status_ExtJs extends Bike_Model_Mapper_Status implements Bike_DataManagement_Interface_ExtJs_Mapper
	{
		static public function getInstance()
		{
			return self::_getInstance(__CLASS__);
		}

		public function getViewPanelButtons(Bike_DataManagement_ExtJs_Buttons $buttons)
		{
			$js = $this->js();

			$buttons->getRefresh()->setDisabled(True);
			$buttons->getEdit()->setDisabled(True);
			$buttons->setTest($buttons->createButton()
				->setTitle('Test')
				->setOrder(1)
				->setUseSelectionModel(True)
				->setHandler($js->function($js->viewWindow)->_body(array(
				$js->alert('testHandler'),
				)))
				->setSubmissionToolbar(True)
				->setSubmissionContextMenu());
		}
	}*/
